/**
 * 
 */
package com.taobao.wolfwolf.hibernate.dao.impl;

import java.util.List;

import org.hibernate.Hibernate;

import com.taobao.wolfwolf.hibernate.dao.SproductDao;
import com.taobao.wolfwolf.hibernate.pojo.Sproduct;

/**
 * @author qinanhg@gmail.com
 *
 * 创建时间: 2012-1-2 下午1:36:03
 */
@SuppressWarnings("unchecked")
public class SproductDaoImpl extends BaseDaoImpl implements SproductDao {

	/* (non-Javadoc)
	 * @see com.taobao.wolfwolf.hibernate.dao.SproductDao#findById(int)
	 */
	@Override
	public Sproduct findById(int id) throws Exception {
		return getHibernateTemplate().get(Sproduct.class, id);
	}
	
	@Override
	public Sproduct findById(boolean lazy, int id) throws Exception {
		Sproduct sproduct = findById(id);
		Hibernate.initialize(sproduct.getType());
		Hibernate.initialize(sproduct.getCcolor());
		Hibernate.initialize(sproduct.getSpecs());
		return null;
	}

	/* (non-Javadoc)
	 * @see com.taobao.wolfwolf.hibernate.dao.SproductDao#findByName(java.lang.String)
	 */
	@Override
	public List<Sproduct> findByName(String name) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see com.taobao.wolfwolf.hibernate.dao.SproductDao#findAll()
	 */
	@Override
	public List<Sproduct> findAll() throws Exception {
		return getHibernateTemplate().loadAll(Sproduct.class);
	}

	/* (non-Javadoc)
	 * @see com.taobao.wolfwolf.hibernate.dao.SproductDao#paging(int, int)
	 */
	@Override
	public List<Sproduct> paging(int page, int limit) throws Exception {
		return super.findByCriteriaByPage(Sproduct.class, page, limit);
	}

	/* (non-Javadoc)
	 * @see com.taobao.wolfwolf.hibernate.dao.SproductDao#getTotal()
	 */
	@Override
	public long getTotal() throws Exception {
		return countByCriteria(Sproduct.class);
	}
}
